<?php
include_once 'Answer_Patterns.php';
include_once 'Mount_DOM_tree.php';

class Refactoring_Old_Tags extends Answer_Patterns {

   public function start($domDocument) {
      $result = "";
      $mount_tree = new Mount_DOM_tree();

      $search = $domDocument->getElementsByTagName('b');

      foreach ($search as $f) {
         if (!empty($f->nodeValue)) {
            $answer = '&LT;strong&GT;';
            $result .= parent::elementAnswerPatterns("&LT;b&GT;", $f->getLineNo(), $answer);
            $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $mount_tree->structHTMLElementRefactory($f, 1, 0, "strong", 1));
         }
      }

      $search = $domDocument->getElementsByTagName('i');
      foreach ($search as $f) {
         if (!empty($f->nodeValue)) {
            $answer = '&LT;em&GT;';
            $result .= parent::elementAnswerPatterns("&LT;i&GT;", $f->getLineNo(), $answer);
            $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $mount_tree->structHTMLElementRefactory($f, 1, 0, "em"));
         }
      }

      if (!empty($result)) {
         $result = parent::titleAnswerPatterns("Substituir tags antigas por novas") . $result;
      }
      return $result;
   }

}
?>

<!--<div class="panel-group" id="accordion">-->
    <!--<div class="panel panel-default">-->
        <!--<div class="panel-heading">-->
            <!--<h4 class="panel-title">-->
                <!--<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">-->
                    <?php // $result ?>
                <!--</a>-->
            <!--</h4>-->
        <!--</div>-->
        <!--<div id="collapseOne" class="panel-collapse collapse">-->
            <!--<div class="panel-body">-->
                <!--<table>-->
                    <!--<tr>-->
                        <!--<th>Elemento Antigo</th>-->
                        <!--<th>Elemento Novo</th>-->
                    <!--</tr>-->
                    <!--</tr>-->
                    <!--<tr>-->
                        <!--<td> $mount_tree->structHTML($f, 1, 0) </td>-->
                        <!--<td>$answer</td>-->
                    <!--</tr>-->                                       
                <!--</table>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->